package com.fwj.base.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * SwaggerConfig
 *
 * @author 樊温军
 * @date 2025/3/19 下午2:37
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    //  配置了Swagger的Docket实例
    @Bean
    public Docket docket(Environment environment) {
        Profiles profiles = Profiles.of("dev", "uat");
        // 如果是dev、uat,这个地方的返回值就是true
        boolean enableSwagger = environment.acceptsProfiles(profiles);
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(enableSwagger)
                .groupName(environment.getProperty("spring.application.name"));
    }

}
